//地点查询函数    
function polygonSearch(type){
    var arr = new Array();
    var min_x = A_Position.getLng() < B_Position.getLng() ? A_Position.getLng() : B_Position.getLng();
    var min_y = A_Position.getLat() < B_Position.getLat() ? A_Position.getLat() : B_Position.getLat();
    var max_x = A_Position.getLng() > B_Position.getLng() ? A_Position.getLng() : B_Position.getLng();
    var max_y = A_Position.getLat() > B_Position.getLat() ? A_Position.getLat() : B_Position.getLat();
    arr.push(new AMap.LngLat(min_x,min_y));
    arr.push(new AMap.LngLat(min_x,max_y));
    arr.push(new AMap.LngLat(max_x,max_y));
    arr.push(new AMap.LngLat(max_x,min_y));
    var polygon = new AMap.Polygon({
        map:g_Map,
        path:arr,
        strokeColor:"#859615",
//        strokeOpacity:0.2,
        strokeWeight:3,
        fillColor: "#ff00b3",
        fillOpacity: 0.25
    });  
   AMap.service(["AMap.PlaceSearch"], function() { //加载PlaceSearch服务插件   
       g_PlaceSearch.setType("");
       g_PlaceSearch.searchInBounds(type, new AMap.Bounds(arr[0], arr[2]), function(status, result){
		  if(status === 'complete' && result.info === 'OK'){
		        		placeSearch_CallBack(result);
		      }else {
                alert("不在服务区，臣妾做不到呀！");
              }
		  });
   });
}

// 选择类型：酒店，咖啡厅，台球厅
function findCafe(){
    doTypeEvent("咖啡厅");
}

function findBilliards(){
    doTypeEvent("台球厅");
}

function findBar(){
    doTypeEvent("酒吧");
}

function findITBar(){
    doTypeEvent("网吧");
}

function findMovie(){
    doTypeEvent("电影院");
}

function findHotel(){
    doTypeEvent("酒店");
}

function findFood(){
    doTypeEvent("美食");
}

function doTypeEvent(type){
    if (!A_Position || !B_Position){
        return alert("请先确定你跟TA的地理位置！");
    }
    A_Select = 0;
    B_Select = 0;
    C_Select = 1;
    polygonSearch(type);
}

function TipContentsTel(type,address,tel){  //窗体内容
    if (type == "" || type == "undefined" || type == null || type == " undefined" || typeof type == "undefined") { 
        type = "暂无"; 
    } 
    if (address == "" || address == "undefined" || address == null || address == " undefined" || typeof address == "undefined") { 
        address = "暂无"; 
    } 
    if (tel == "" || tel == "undefined" || tel == null || tel == " undefined" || typeof address == "tel") { 
        tel = "暂无"; 
    } 
    var str ="  地址：" + address + "<br />  电话：" + tel + " <br />  类型："+type; 
    return str; 
} 

function doCposition(){
    console.log("C lng : "+C_Position.getLng()+", lat : " + C_Position.getLat());
}